from django.contrib import admin
from .models import NoticeModel,NoticeMembersModel


# Register your models here.

class NoticeAdmin(admin.ModelAdmin):
    list_display = ['title', 'content','creater_name','notice_type']
    def creater_name(self,obj):
        return obj.creater.first_name
    creater_name.short_description = "创建人"
    list_display_links = ['title', 'content','creater_name','notice_type']
    search_fields = ['title','content']
    readonly_fields = ['create_time']
    list_filter = ['creater', 'notice_type']


class NoticeMembersAdmin(admin.ModelAdmin):
    def user_name(self,obj):
        return obj.user.first_name
    user_name.short_description = "完成人"
    list_display = ['notice','user_name','done']
    list_display_links = ['notice', 'user_name', 'done']
    search_fields = ['work__name']
    list_filter = ['notice','done', 'notice__notice_type']

admin.site.register(NoticeModel, NoticeAdmin)
admin.site.register(NoticeMembersModel, NoticeMembersAdmin)
